﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Collections;

using System.ComponentModel;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Xml;
using System.Xml.XPath;
using System.Configuration;
using AdaptiveHelpDesk;

namespace Novice.Services.Processing
{
    /// <summary>
    /// Summary description for DataAccess
    /// </summary>
    [WebService(Namespace = "http://soaiui.nmmu.ac.za/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class DataAccess : System.Web.Services.WebService
    {
        StoredProcedures sp = new StoredProcedures();

      
        //calls the stored procedure that searches the customer by first name
        [WebMethod]
        public Hashtable getCustomer(String by, String param)
        {
            return sp.getCustomer(by, param);
        }
        #region INSERT USER PROFILE
        [WebMethod]
        public void InsertUserProfile(string UID, string fName, string lName, string date, string time, string stereotype)
        {
            sp.InsertUserProfile(UID, fName, lName, date, time, stereotype);
        }
        #endregion
        //just update display solution screen and timecompleted columns of User Profile
        #region UPDATE USER PROFILE
            [WebMethod]    
            public void updateUserModelDisplaySolScreenAndTimeCompleted(string UserID, string dateLogged, string timeLogged, string displaySolScreen, int TTime, string timeComplete)
            {
                sp.updateUserModelDisplaySolScreenAndTimeCompleted(UserID, dateLogged, timeLogged, displaySolScreen, TTime, timeComplete);
            }
        #endregion
        #region getTotalTaskTimeUSERPROFILE
            [WebMethod]
            public ArrayList getTotalTaskTime(string UserID, string DisplaySol)
            {
                return sp.getTotalTaskTime(UserID, DisplaySol);
            }
            [WebMethod]
            public ArrayList getTotalTaskTimeAll(string DisplaySol)
            {
                return getTotalTaskTimeAll(DisplaySol);
            }
        #endregion
        #region getDisplaySolutionUSERPROFILE
            [WebMethod]
            public ArrayList getDisplaySolution(string UserID)
            {
                return sp.getDisplaySolution(UserID);
            }
            [WebMethod]
            public int getNrRowsDisplaySolution(string UserID, string YN)
            {
                return sp.getNrRowsDisplaySolution(UserID, YN);
            }
        #endregion
        //Verify User
        [WebMethod]
        public ArrayList getPassword(string param)
        {
            return sp.getPassword(param);
        }
        //Call Log Stored Procedures
        #region
            [WebMethod]
            public BindingList<string> getPriority()
            {
                return sp.getPriority();   
            }
            [WebMethod]
            public String getSeverity(int param)
            {
                return sp.getSeverity(param);
            }
            [WebMethod]
            public BindingList<string> getServiceNames()
            {
                return sp.getServiceNames();
            }
            [WebMethod]
            public BindingList<string> getCallSource()
            {
                return sp.getCallSource();
            }
            [WebMethod]
            public BindingList<string> getCallType(String param)
            {
                return sp.getCallType(param);
            }
            [WebMethod]
            public BindingList<string> getSubCallType(String param)
            {
                return sp.getSubCallType(param);
            }
            [WebMethod]
            public string[,] getCallTypeALL()
            {
                return sp.getCallTypeALL();
            }
            [WebMethod]
            public string[,] getSubCallTypeALL()
            {
                return sp.getSubCallTypeALL();
            }
            [WebMethod]
            public string check_If_CALLID_exists(string cID)
            {
                return sp.check_If_CALLID_exists(cID);
            }
            [WebMethod]
            public String getMAxCallID()
            {
                return sp.getMAxCallID();
            }
            //Log a call
            [WebMethod]
            public void LogACall(string cID, string date, string time,string userID, string custID, string sName, string cType, string scType, string status, string priority, string cSource, string cDescr)
            {
                sp.LogACall(cID, date, time, userID, custID, sName, cType, scType,status, priority, cSource, cDescr);
            }
        #endregion
        //Assign A Call
        #region
            [WebMethod]
            public BindingList<string> getCampus()
            {
                return sp.getCampus();
            }
            //gets all assigneeID's located on specified campus 
            [WebMethod]
            public BindingList<string> getAssigneeID(string param)
            {
                return sp.getAssigneeID(param);
            }
            [WebMethod]
            //gets all assignee details with specified assigneeID
            public ArrayList getAssigneeDetails(string param)
            {
                return sp.getAssigneeDetails(param);
            }
            [WebMethod]
            public BindingList<string> getAssigneeIDAll()
            {
                return sp.getAssigneeIDAll();
            }
            //Assign a call
            [WebMethod]
            public void AssignACall(string cID, string assignID, string gName, string aName, string date, string time, string comments)
            {
                sp.AssignACall(cID, assignID, gName, aName, date, time, comments);
            }
            [WebMethod]
            public string check_If_CALLID2_exists(string cID)
            {
                return check_If_CALLID2_exists(cID);
            }
        #endregion
        //Provide Solution
        #region
            //get Call Cause
            [WebMethod]
            public BindingList<string> getCause(string param)
            {
                return sp.getCause(param);
            }
            //get How Resolved
            [WebMethod]
            public BindingList<string> getResolvedHow()
            {
                return sp.getResolvedHow();
            }
            [WebMethod]
            public string[,] getCauseAll()
            {
                return sp.getCauseAll();
            }
            //Update Call Log with Solution Details
            [WebMethod]
            public void updateCallLog(string cID, string cause, string resolveHow, string solDescr)
            {
                sp.updateCallLog(cID, cause, resolveHow, solDescr);
            }
        #endregion
        #region EXPERT UI - RECENTLY&FREQUENTLY USED 
            #region RECENTLY
                [WebMethod]
                public String getRecentlyUsedItem(string UserID, string listName)
                {
                    return sp.getRecentlyUsedItem(UserID, listName);
                }
                [WebMethod]
                public void updateRecentlyUsedItem(string UserID, string listName, string recentlyUsedItem)
                {
                    sp.updateRecentlyUsedItem(UserID, listName, recentlyUsedItem);
                }
                [WebMethod]
                public void insertRecentlyUsedItem(string UserID, string listName, string recentlyUsedItem)
                {
                    sp.insertRecentlyUsedItem(UserID, listName, recentlyUsedItem);
                }
            #endregion
            #region FREQUENTLY
                [WebMethod]
                public ArrayList getTop3FrequentlyUsedItems(string UserID, string listName)
                {
                    return sp.getTop3FrequentlyUsedItems(UserID, listName);
                }
                [WebMethod]
                public int getFrequency(string UserID, string listName, string itemName)
                {
                    return sp.getFrequency(UserID, listName, itemName);
                }
                [WebMethod]
                public void updateFrequentlyUsedItem(string UserID, string listName, string itemName, int frequency)
                {
                    sp.updateFrequentlyUsedItem(UserID, listName, itemName, frequency);
                }
                [WebMethod]
                public void insertFrequentlyUsedItem(string UserID, string listName, string itemName, int frequency)
                {
                    sp.insertFrequentlyUsedItem(UserID, listName, itemName, frequency);
                }
            #endregion
        #endregion    
    }
}
